package com.ricci.synergybridge.exception;

import com.ricci.synergybridge.common.ErrorCode;
import lombok.Getter;

import java.io.Serial;

/**
 * 业务异常
 * @author 陈万三
 * @create 2024-02-02 19:16
 */
@Getter
public class BusinessException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = 4779314069364964372L;
    private final int code;

    private final String description;

    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }

}
